import Vue from 'vue'
import App from './App.vue'
import store from './store'
import './assets/css/reset.scss'
import 'animate.css'
import './assets/css/anmi.scss'
import './assets/css/font.scss'
import { isDev, wechatAuth } from '@/common/config'
import CommonView from '@/components/CommonView.vue'
import DesignView from '@/components/DesignView.vue'
// 完整加载
import VueLuckyCanvas from '@lucky-canvas/vue'
import MusicController from '@/common/MusicController.js'
import '@/common/VueExtendProtptype.js'
import bgMusic from '@/assets/audio/bg.mp3'
import clickAudio from '@/assets/audio/click.mp3'
import { Howl } from 'howler'
// eslint-disable-next-line no-new
Vue.prototype.$bgm = new MusicController(bgMusic)
Vue.prototype.$sound = new Howl({
  src: [clickAudio]
})

Vue.config.productionTip = false
Vue.component('CommonView', CommonView)
Vue.component('DesignView', DesignView)
Vue.use(VueLuckyCanvas)

if (!isDev) {
  wechatAuth.auth().then(res => {
    return createApp()
    // if (wechatAuth.userInfo) {
    //   const { nickname, headimgurl } = JSON.parse(wechatAuth.userInfo)
    //   store.commit(UPDATE_USERINFO, { nickname, headimgurl })
    //   createApp()
    // } else {
    //   showMsg('微信授权失败')
    // }
  }).catch(err => {
    console.log('【微信授权失败】：', err)
  })
} else {
  createApp()
}

// 创建app
function createApp () {
  new Vue({
    store,
    render: h => h(App)
  }).$mount('#app')
}
